using System.IO;

namespace ZerAx.TBON
{
    public class TbonString : TbonObject
    {
        static TbonString()
        {
            factories.Add(TbonType.String, (s) => new TbonString(s));
        }

        public override TbonType Type => TbonType.String;
        public string val;

        public TbonString(string name) : base(name) { }
        public TbonString(string name, string val) : this(name)
        {
            this.val = val;
        }

        public override string GetValueString() => $"\"{val}\"";

        public override void ReadValue(BinaryReader reader)
        {
            val = reader.ReadString();
        }

        public override void WriteValue(BinaryWriter writer)
        {
            writer.Write(val);
        }
    }
}